/**
 * <p>Copyright:Copyright(c) 2019</p>
 * <p>Company:Professional</p>
 * <p>Package:ces.org.course.cfg</p>
 * <p>File:CesConfiguration.java</p>
 * <p>类更新历史信息</p>
 * @todo chanlong(陈龙) 创建于 May 20, 2019 4:11:36 PM
 */
package com.ces.group.cfg;

import ces.org.course.api.event.FileUploadEvent;
import ces.org.course.api.event.FileUploadListener;
import ces.org.course.api.watch.FileListenerFactory;
import ces.org.course.api.watch.FileListenerRunner;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import lombok.Data;

/**
 * <p>描述: </p>
 * <p>Company: Professional</p>
 * @author chanlong(陈龙)
 * @date May 20, 2019 4:11:36 PM
 * @version 1.0.2019
 */
@Data
@Configuration
@EnableConfigurationProperties({DictProperties.class, FileProperties.class})
public class CesConfiguration {

	private FileProperties file;
	
	private DictProperties dict;


	@Bean
	@ConditionalOnProperty(prefix = "ces.dict.",value = "trigger",havingValue = "event")
	public FileUploadListener fileUploadListener(){
		return new FileUploadListener();
	}

	@Configurable
	@ConditionalOnProperty(prefix = "ces.dict.",value = "trigger",havingValue = "auto",matchIfMissing = true)
	public static class AutoFileListener{
		@Bean
		public FileUploadListener fileUploadListener2(){
			return new FileUploadListener(){
				@Override
				public void listener(FileUploadEvent event) {
				}
			};
		}
		@Bean
		public FileListenerRunner fileListenerRunner(){
			return new FileListenerRunner();
		}
		@Bean
		public FileListenerFactory fileListenerFactory(){
			return new FileListenerFactory();
		}
	}
}
